package com.mapper;

import com.entity.Book;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017/6/15.
 */
public interface BookMapper {

    /*@Select("insert into book values(null,#{name},#{price})")
    public int save01(Book book);

    @Delete("delete from book where id=#{id}")
    public int deleteById(int id );

    @Insert("insert into book value(null,#{name},#{price})")
    public  int save(Book book);
    @Update("update book set name=#{name} where id=#{id}")
    public int update(@Param("name") String name,@Param("id") int id);


    @Update("insert into book values(null,#{name},#{price})")
    public  int addBook(Map<String,Object> map);
*/


    public List<Book> queryAll();

    public Book queryById(int id);

    public List<Book> page(Map<String,Integer> map);

    public int delete();

    public int deleteById(int id);

    public  int add(Book book);

    public int save(Map<String,Object> map);

    public int update(Book book);

    public int updateById(Map<String ,Object> map);

    public List<Book> page02(RowBounds rowBounds);

   /* @Select("select * from book limit #{ss},#{ee}") @ResultMap("bk")*/
    public List<Book> mypage(@Param("ss") int ss, @Param("ee") int ee);


    @Select("show databases")
    public List<Map<String,Object>> showDbs();


    @Select("show databases")
    public List<String> showDbs2();

    @Insert("insert into book values(bid.nextval,#{name},#{price})")
    public int osave(@Param("name") String name, @Param("price") double price);


    @Select("select book_i,book_n,book_p from (select rownum rn, b.* from book b) bb where rn between #{ss} and #{ee}") @ResultMap("bk")
    public List<Book> opage(@Param("ss") int ss,@Param("ee") int ee);

    @Select("select * from book where name_n=#{na}") @ResultMap("bk")
    public Book queryByName( String na);

    /*面向过程*/
    public int delbook(int id);

    public int addBook(Map<String,Object> map);

    public List<Book> showbook();


    public void bookcc(Map<String,Object> map);

   /* 动态方法*/

   public List<Book> dongQuery();

   public List<Book> dongQuery(Map<String,Object> map);

   public int dongupdate(Map<String,Object> map);

   public List<Book> dongQuwhen(Map<String,Object> map);

   public List<Book> dongwhere(Map<String,Object> map);

    public int dongset(Map<String,Object> map);


    public List<Book> dongForeach(Map<String,Object> map);


    public  int dongDelete(Map<String,Object> map);




}
